<?php 

class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
		if ($this->_getParam('fmsg')) {
			$flashMessenger = $this->_helper->FlashMessenger;
			$flashMessenger->setNamespace($this->_getParam('fmsg'));
			$this->view->flashMessages = $flashMessenger->getMessages();
		}

		//TODO: parameter for narrow or wide or loose


		$this->view->panel0Widgets = array();
		$this->view->panel1Widgets = array();


		if (Kernel::getInstance()->isWidgetActive('activities')) {
			$widget = Kernel::getInstance()->getWidget('activities');
			$widget->setTitle('Recent Activities');
			$this->view->panel0Widgets[] = $widget;
		}

		if (Kernel::getInstance()->isWidgetActive('shoutbox')) {
			$this->view->panel0Widgets[] = Kernel::getInstance()->getWidget('shoutbox');
		}

		//TODO: configurable what to show
		if (Kernel::getInstance()->isWidgetActive('login')) {
			if (Account_Model_Session::hasValidSession() === FALSE) {
				$this->view->panel1Widgets[] = Kernel::getInstance()->getWidget('login');
			}
		}

		if (Kernel::getInstance()->isWidgetActive('users')) {
			$widget = Kernel::getInstance()->getWidget('users');
			$widget->setTitle('Latest Members');
			$this->view->panel1Widgets[] = $widget;
		}

		if (Kernel::getInstance()->isWidgetActive('groups')) {
			$widget = Kernel::getInstance()->getWidget('groups');
			$widget->setTitle('Latest Groups');
			$this->view->panel1Widgets[] = $widget;
		}


		$this->view->requestParams = $this->getRequest()->getParams();
		$this->view->requestParams['widget_display_mode'] = 'small';
    }
}
